package com.madarasan.notneeded;



import java.util.ArrayList;




import android.os.Parcel;

import android.os.Parcelable;



public class CustomersList extends ArrayList<Customer> implements Parcelable{



       private static final long serialVersionUID = 663585476779879096L;



       public CustomersList(){

              

       }

      

       public CustomersList(Parcel in){

               readFromParcel(in);

       }

      

       @SuppressWarnings({ "rawtypes" })

       public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {

               public CustomersList createFromParcel(Parcel in) {

                       return new CustomersList(in);

               }



               public Object[] newArray(int arg0) {

                       return null;

               }



       };

      

       private void readFromParcel(Parcel in) {

               this.clear();



               //First we have to read the list size

               int size = in.readInt();



               //Reading remember that we wrote first the Name and later the Phone Number.

               //Order is fundamental

              

               for (int i = 0; i < size; i++) {

                       Customer c = new Customer();

                       c.setTitle(in.readString());

                       c.setLink(in.readString());
                       
                       c.setDescription(in.readString());
                       
                       c.setTempMax(in.readString());
                       
                       c.setTempMin(in.readString());
                       
                       c.setWind(in.readString());
                       
                       c.setSnow(in.readString());
                       
                       c.setWeather(in.readString());
                       
                       c.setDate(in.readString());
                       
                       

                       this.add(c);

               }

              

       }



       public int describeContents() {

               return 0;

       }



       public void writeToParcel(Parcel dest, int flags) {

               int size = this.size();

               //We have to write the list size, we need him recreating the list

               dest.writeInt(size);

               //We decided arbitrarily to write first the Name and later the Phone Number.

               for (int i = 0; i < size; i++) {

                       Customer c = this.get(i);

                       dest.writeString(c.getTitle());
                       
                       dest.writeString(c.getLink());
                       
                       dest.writeString(c.getDescription());
                       
                       dest.writeString(c.getTempMax());
                       
                       dest.writeString(c.getTempMin());
                       
                       dest.writeString(c.getWind());
                       
                       dest.writeString(c.getSnow());
                       
                       dest.writeString(c.getWeather());
                       
                       dest.writeString(c.getDate());

               }

       }

 



}


